package abak.tr.com.boxedverticalseekbar;

import abak.tr.com.boxedverticalseekbar.utils.PxUtil;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class PxUtilTest {
    /**
     * PxUtil中convertTouchEventPointValue方法测试
     */
    @Test
    public void convertTouchEventPointValue() {
        int scrHeight = 1920;
        float value = 2000f;
        double point = PxUtil.convertTouchEventPointValue(scrHeight, value);
        assertNotNull(point);
        assertEquals("2000.0", String.valueOf(point));
    }

    /**
     * PxUtil中mathValue方法测试
     */
    @Test
    public void mathValue() {
        double touch = 1920;
        int point = PxUtil.mathValue(touch);
        assertNotNull(point);
        assertEquals("1920", String.valueOf(point));
    }

    /**
     * PxUtil中getProgress方法测试
     */
    @Test
    public void getProgress() {
        int scrHeight = 1920;
        int progress = -2000;
        int pValue = PxUtil.getProgress(scrHeight, progress);
        assertNotNull(pValue);
        assertEquals("0", String.valueOf(pValue));
    }

    /**
     * PxUtil中getPoints方法测试
     */
    @Test
    public void getPoints() {
        int scrHeight = 1920;
        int progress = 200;
        int mMax = 100;
        int mMin = 0;
        int points = PxUtil.getPoints(scrHeight, progress, mMax, mMin);
        assertNotNull(points);
        assertEquals(90, points);
    }
}
